package com.huixue.cn.ztej.api.controller;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.alibaba.fastjson.JSON;
import com.huixue.cn.ztej.bean.Results;
import com.huixue.cn.ztej.controller.BaseController;
import com.huixue.cn.ztej.utils.SystemContents.API_RETURN_STATUS;
import com.huixue.cn.ztej.weixin.bean.XiaoOAuthInfo;
import com.huixue.cn.ztej.weixin.util.WeixinHelper;

@Controller
@RequestMapping(value = "/api/weixin")
public class ApiWexinController extends BaseController {
	
	/**
	 * 获取OpenId
	 * @param request
	 * @param response
	 * @param attrs
	 * @return
	 */
	@RequestMapping(value = "/getOpenId",produces="application/json;charset=UTF-8")
	@ResponseBody
	public String getOpenId(HttpServletRequest request,HttpServletResponse response,RedirectAttributes attrs ) {
		XiaoOAuthInfo xiaoOAuthInfo = WeixinHelper.getXiaoChengXuUserOpenId(request);
		Results results = new Results(API_RETURN_STATUS.NORMAL.value(),API_RETURN_STATUS.NORMAL.desc(),xiaoOAuthInfo);
		return JSON.toJSONString(xiaoOAuthInfo);
	}
	
	/**
	 * 微信消息推送
	 * @param request
	 * @param response
	 * @param attrs
	 * @return
	 */
	@RequestMapping(value = "/pushMessage",produces="application/json;charset=UTF-8")
	@ResponseBody
	public String pushMessage(HttpServletRequest request,HttpServletResponse response,RedirectAttributes attrs ) {
		return JSON.toJSONString("");
	}
	
}
